package com.androidx.p013lv.mine.activity;

import android.view.View;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.listener.ItemClickListener;
import com.androidx.p013lv.base.p015ui.BaseActivity;
import com.androidx.p013lv.base.utils.TimeUtils;
import com.androidx.p013lv.base.utils.ToastUtils;
import com.androidx.p013lv.base.utils.UiUtils;
import com.androidx.p013lv.mine.C1207R;
import com.androidx.p013lv.mine.adapter.ContactOfficialAdapter;
import com.androidx.p013lv.mine.bean.RentalBean;
import com.androidx.p013lv.mine.databinding.ActivityContactOfficialLayoutBinding;
import com.androidx.p013lv.mine.model.ContactOfficialModel;
import com.gyf.immersionbar.ImmersionBar;
import java.util.List;

/* renamed from: com.androidx.lv.mine.activity.ContactOfficialActivity */
public class ContactOfficialActivity extends BaseActivity<ActivityContactOfficialLayoutBinding> implements ItemClickListener {
    private ContactOfficialAdapter adapter;
    private ContactOfficialModel model;

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this).titleBar(((ActivityContactOfficialLayoutBinding) this.binding).toolbar).init();
    }

    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public int setLayout() {
        return C1207R.C1212layout.activity_contact_official_layout;
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initView() {
        super.initView();
        ((ActivityContactOfficialLayoutBinding) this.binding).setClick(new OnClick());
        this.model = (ContactOfficialModel) new ViewModelProvider(this).get(ContactOfficialModel.class);
        ContactOfficialAdapter contactOfficialAdapter = new ContactOfficialAdapter();
        this.adapter = contactOfficialAdapter;
        contactOfficialAdapter.setItemListener(this);
        ((ActivityContactOfficialLayoutBinding) this.binding).recycler.setLayoutManager(new LinearLayoutManager(this));
        ((ActivityContactOfficialLayoutBinding) this.binding).recycler.setAdapter(this.adapter);
        ((ActivityContactOfficialLayoutBinding) this.binding).tvTitle.setText(String.format(getString(C1207R.string.contact_official_title), TimeUtils.getCapitalMonth()));
        this.model.data().observe(this, new Observer<BaseRes<List<RentalBean>>>() {
            /* class com.androidx.p013lv.mine.activity.ContactOfficialActivity.C12231 */

            public void onChanged(BaseRes<List<RentalBean>> baseRes) {
                if (baseRes.getCode() == 200) {
                    ContactOfficialActivity.this.adapter.setData(baseRes.getData());
                } else {
                    ToastUtils.getInstance().showSigh(baseRes.getMsg());
                }
            }
        });
        this.model.setLiveData(this);
        ((ActivityContactOfficialLayoutBinding) this.binding).tvDesc.setText(C1207R.string.contact_official_text);
    }

    @Override // com.androidx.p013lv.base.listener.ItemClickListener
    public void onItemClick(View view, int i) {
        if (view.getId() == C1207R.C1210id.tv_copy) {
            copyContactNo(((RentalBean) this.adapter.getDataInPosition(i)).getContactNo());
        }
    }

    private void copyContactNo(String str) {
        if (!UiUtils.copyContentClipboard(str)) {
            ToastUtils.getInstance().showWrong("復制失敗");
        } else {
            ToastUtils.getInstance().showCorrect("復制成功");
        }
    }

    /* renamed from: com.androidx.lv.mine.activity.ContactOfficialActivity$OnClick */
    public class OnClick {
        public OnClick() {
        }

        public void btnBack() {
            ContactOfficialActivity.this.finish();
        }
    }

    /* access modifiers changed from: protected */
    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, com.androidx.p013lv.base.p015ui.BaseActivity
    public void onDestroy() {
        ContactOfficialModel contactOfficialModel = this.model;
        if (contactOfficialModel != null) {
            contactOfficialModel.cancelHttp();
        }
        super.onDestroy();
    }
}
